	SelectersCount = 0;
		
		

			function NewSelecter()
			{
				AjaxCallStatus = GetObjects("svc/search/getmodelsnames");
				AjaxCallStatus.then(function()
				{
					var XMLresp = GetLastAJAXResponse();
					new ModelSelecter(XMLresp);
				});
				AjaxCallStatus.fail(function()
				{
					CreateErrorWindow("Error!."
							+ " Check connection with server. " +
							"Cause: " + GetLastAJAXResponse());
					DialogResult.reject("fail");
					
				});
				
				
			}

			
			
	    function ModelSelecter(XMLresp)
		{
	    	    	
	    	this.XMLresponse = XMLresp;
		
			//Hay que llevar los ID's del DOM creado Dinamicamente	
			var SelecterID = "ModelSelecter-"+SelectersCount;
				
			$('body').append("<ul id='"+SelecterID+"'></ul>");
							
			
			SelectersCount++;
			
			//foreach object tag
			$(this.XMLresponse).find('name').each
			(function()
			{
				var FullName = $(this).text();
				var SplittedName = FullName.split(".");
				
				if (SplittedName.length > 1) //Has package and class name
				{
					var PackageName = SplittedName[0];
					var ModelName = SplittedName[1];
					
					if ($('ul[id='+SelecterID+']').children('li[id='+PackageName+']').children('ul[id='+PackageName+']').length > 0) //if the menu already have a container for this package
					{
						  $('ul[id='+PackageName+']').append("<li><a href='#'>"+ModelName+"</a></li>");
					}
					else //if the menu doesn't have a container for this package and its models
					{
						$('ul[id='+SelecterID+']').append("<li id='"+PackageName+"' class='package'><a href='#'>"+PackageName+"</a><ul id='"+PackageName+"'></ul></li>" );
						$('ul[id='+SelecterID+']').children('li[id='+PackageName+']').children('ul[id='+PackageName+']').append("<li><a href='#'>"+ModelName+"</a></li>");
					}
				}
				else //it's outside a package, just class name
				{
					$('#'+ SelecterID).append("<li><a href='#'>"+FullName+"</a></li>" );//un row por objeto
				}
				
				 
		
				

			});
				
			$('#'+SelecterID).menu
			({select: 
					function(event, ui) 
					{
			            var index = ui.item.attr('class').indexOf('package');
						if (!(ui.item.attr('class').indexOf('package') >= 0)) //if the menu item doesn't contains the "package" css class
			            {
						var ModelName = ui.item.text();
			            var PackageName = ui.item.parent().parent().children('a').contents().filter(function(){
		                       //return true only if text node
		                       return this.nodeType == 3;
		                  }).text();
			            var FinalName = PackageName +"."+ ModelName;
			            var ServicePath = "svc/crud";
			            var ServiceParams = "model="+FinalName+"&Page=1";
			            
			            NewCrudWindow(ServicePath,ServiceParams, FinalName);
			            }
			            
					}	
			});
			
			
		}
		
			
	